#include <stdio.h>
#include <string.h>

char change(char c, int n)
{
    char key=1;
    key<<=n;
    if(key&c)  c=c&~key;
    else       c=c|key;
    return c;
}

char* crypto(char* s, int n)
{
    int len = strlen(s);
    for (int i = 0; i < len; i++)
    {
        s[i] = change(s[i], n);
    }
    return s;
}

int main()
{
    char str[50] = { 0 };
    int n = 0;
    gets(str);
    scanf("%d", &n);
    crypto(str, n);
    printf("JiaMi:%s\n", str);
    crypto(str, n);
    printf("JieMi:%s\n", str);
    return 0;
}